package com.binance.mbxgateway.api;

import java.util.List;

import com.binance.mbxgateway.vo.request.api.ApiKeyModelRequest;
import com.binance.mbxgateway.vo.request.api.GetApiListRequest;
import com.binance.mbxgateway.vo.request.api.SearchDeletedApiRequest;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import com.binance.master.configs.FeignConfig;
import com.binance.master.constant.Constant;
import com.binance.master.models.APIRequest;
import com.binance.master.models.APIResponse;
import com.binance.mbxgateway.annotation.Source;
import com.binance.mbxgateway.vo.request.api.DeleteAllApiKeyRequest;
import com.binance.mbxgateway.vo.request.api.DeleteApiKeyRequest;
import com.binance.mbxgateway.vo.request.api.EnableApiCreateRequest;
import com.binance.mbxgateway.vo.request.api.EnableApiWithdrawRequest;
import com.binance.mbxgateway.vo.request.api.GetApisRequest;
import com.binance.mbxgateway.vo.request.api.SaveApiKeyRequest;
import com.binance.mbxgateway.vo.request.api.SearchApiRequest;
import com.binance.mbxgateway.vo.request.api.UpdateApiKeyRequest;
import com.binance.mbxgateway.vo.response.PagingResult;
import com.binance.mbxgateway.vo.response.api.ApiModelResponse;
import com.binance.mbxgateway.vo.response.api.EnableApiWithdrawResponse;
import com.binance.mbxgateway.vo.response.api.UpdateApiKeyResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api
@FeignClient(name = Constant.MBX_GATEWAY_SERVICE, configuration = FeignConfig.class)
public interface IApi {

    @ApiOperation("根据条件查询Api信息")
    @PostMapping("/apiManage/getList")
    @Source(value = "PNK", originalUrl = "/apiManage/getList.html")
    public APIResponse<PagingResult<ApiModelResponse>> loadApiList(@RequestBody APIRequest<SearchApiRequest> request)
            throws Exception;

    @PostMapping("/query-api-userandapikey")
    @ApiOperation("根据userId和apiKey查询API信息。参数中只有userId和apiKey会参与查询，而且系统会校验其不能为空")
    public APIResponse<ApiModelResponse> queryApiByUserAndApiKey(@RequestBody APIRequest<SearchApiRequest> request)
            throws Exception;

    @ApiOperation("根据条件查询删除的Api信息")
    @PostMapping("/mbx/getDeletedList")
    public APIResponse<PagingResult<ApiModelResponse>> loadDeletedApiList(
            @RequestBody APIRequest<SearchDeletedApiRequest> request) throws Exception;

    @ApiOperation("提供给老代码使用，老代码删除apikey后要调用该接口保存删除的apikey")
    @PostMapping("/mbx/addDeletedApi")
    public APIResponse<Void> addDeletedApi(@RequestBody APIRequest<ApiKeyModelRequest> request) throws Exception;

    @ApiOperation("创建API，并返回这条API信息")
    @PostMapping("/mgmt/account/createApiKey")
    public APIResponse<ApiModelResponse> createApiKey(@RequestBody APIRequest<SaveApiKeyRequest> request)
            throws Exception;

    @ApiOperation("")
    @PostMapping("/mgmt/account/updateApiKey")
    public APIResponse<UpdateApiKeyResponse> updateApiKey(@RequestBody APIRequest<UpdateApiKeyRequest> request)
            throws Exception;

    @ApiOperation("")
    @PostMapping("/mgmt/account/deleteApiKey")
    public APIResponse<Void> deleteApiKey(@RequestBody APIRequest<DeleteApiKeyRequest> request) throws Exception;

    @ApiOperation("")
    @PostMapping("/mgmt/account/deleteAllApiKey")
    public APIResponse<Void> deleteAllApiKey(@RequestBody APIRequest<DeleteAllApiKeyRequest> request) throws Exception;

    @PostMapping(value = "/manageApi/enableApiCreate")
    @Source(value = "PNK", originalUrl = "/manageApi/enableApiCreate.html")
    public APIResponse<ApiModelResponse> enableApiCreate(@RequestBody APIRequest<EnableApiCreateRequest> request)
            throws Exception;

    // @PostMapping(value = "/manageApi/enableApiCreate/reSendMailVerify")
    // @Source(value = "PNK", originalUrl = "/manageApi/enableApiCreate/reSendMailVerify.html")
    // public APIResponse<Void> reSendMailVerify(@RequestBody APIRequest<ReSendMailVerifyRequest>
    // request)
    // throws Exception;

    @PostMapping(value = "/manageApi/enableApiWithdraw")
    @Source(value = "PNK", originalUrl = "/manageApi/enableApiWithdraw.html")
    public APIResponse<EnableApiWithdrawResponse> enableApiWithdraw(
            @RequestBody APIRequest<EnableApiWithdrawRequest> request) throws Exception;

    // @PostMapping(value = "/manageApi/enableApiWithdraw/reSendMail.html")
    // public APIResponse<Void> reSendMail(@RequestBody APIRequest<ReSendMailRequest> request)
    // throws Exception;

    @PostMapping(value = "/manageApi/getApis")
    @Source(value = "PNK", originalUrl = "/manageApi/getApis.html")
    public APIResponse<List<ApiModelResponse>> getApis(@RequestBody APIRequest<GetApisRequest> request)
            throws Exception;

    // @PostMapping(value = "/manageApi/disableApiById.html")
    // public APIResponse<Void> disableApiById(@RequestBody APIRequest<DisableApiByIdRequest>
    // request) throws Exception;

    @ApiOperation("根据id、userId、apiKy、apiName四个参数进行查询，各个参数都可能为空")
    @PostMapping(value = "/api/getApiList")
    public APIResponse<List<ApiModelResponse>> getApiList(@RequestBody APIRequest<GetApiListRequest> request)
            throws Exception;
}
